package junior.util.wrap;

import java.io.Serializable;

/**
 * 封装对象和一个布尔标志
 * 
 * @param <T>
 * @author ZhangXiaoye
 * @date 2016年10月6日 上午9:15:13
 */
public class Marked<T> implements Serializable{
	
	/** 说明  */
	private static final long serialVersionUID = 1L;

	public final Boolean mark;
	
	public final T value;

	public Marked(T value, Boolean mark){
		this.value = value;
		this.mark = mark;
	}

	public Boolean isMark() {
		return mark;
	}

	public T getValue() {
		return value;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((mark == null) ? 0 : mark.hashCode());
		result = prime * result + ((value == null) ? 0 : value.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Marked)) {
			return false;
		}
		@SuppressWarnings("rawtypes")
		Marked other = (Marked) obj;
		if (mark == null) {
			if (other.mark != null) {
				return false;
			}
		} else if (!mark.equals(other.mark)) {
			return false;
		}
		if (value == null) {
			if (other.value != null) {
				return false;
			}
		} else if (!value.equals(other.value)) {
			return false;
		}
		return true;
	}

	public String toString(){
		return "Marked<" + (value != null? value.getClass().getName(): "Void") + ">(" + value + ", " + mark + ")";
	}
	
}
